package moni.anyou.com.view.view.account.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import moni.anyou.com.view.R;


public class SelectKinderGartenAdapter extends BaseAdapter {
    private Context context;
    private JSONArray typeName;

    public  SelectKinderGartenAdapter(Context context,JSONArray typeName){
        this.context=context;
        this.typeName=typeName;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return typeName.length();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if (convertView==null) {
            holder=new ViewHolder();
            convertView=LayoutInflater.from(context).inflate(R.layout.adapter_select_item, parent, false);
            holder.tvTypeName=(TextView) convertView.findViewById(R.id.tv_title);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        try{
            holder.tvTypeName.setText(((JSONObject)typeName.get(position)).getString("company"));
        }
        catch(Exception ex){

        }
        return convertView;
    }

    public class ViewHolder{
        TextView tvTypeName;
    }

}
